# 第二周作业
products = [["iphone", 6888], ["MacPro", 14800], ["小米6", 2499], ["Coffee", 31], ["Book", 60], ["Nike", 699]]
products = dict(enumerate(products))

shop_car = []
shop_cost = []

for i, (k, v) in products.items():
    print("{}. {}|{}".format(i,k,v))

while True:
    item_index = input(">>> enter item index(0-5) to purchase or 'q' to quit: ")
    if item_index == 'q':
        print("------- 商品列表 -------")
        for item, cost in zip(shop_car, shop_cost):
            print("{}, {}".format(item, cost))
        break
    elif item_index.isdigit() and 0 <= int(item_index) <= 5 :
        shop_car.append(products.get(int(item_index))[0])
        shop_cost.append(products.get(int(item_index))[1])
    else:
        print("unknown index")
# 除了没有购买的成功后的提示，别的没有什么问题